﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MagicArena.framework.toon;

namespace MagicArena.framework.physics
{
    public abstract class ACollider : IToonComponent
    {
        public delegate void OnCollisionHandler(object sender, CollisionEventArgs e);
        public class CollisionEventArgs : EventArgs
        {
            public ACollider Other
            {
                get;
                private set;
            }
            public CollisionEventArgs(ACollider other)
            {
                Other = other;
            }
        }

        public bool HasToon
        {
            get;
            private set;
        }
        public Toon Toon
        {
            get;
            private set;
        }

        public ACollider()
        {
            HasToon = false;
        }

        public event OnCollisionHandler Collision;

        public virtual void OnCollision(ACollider other)
        {
            Collision(this, new CollisionEventArgs(other));
        }

        public void AttachToToon(Toon t)
        {
            if(t!=null)
                HasToon = true;
            Toon = t;
        }
    }
}
